<!DOCTYPE html>
<html>
<head>
    <title>Error - SiYuan</title>
    <meta charset="UTF-8">
    <style>
        body {
            margin: 0;
            background-color: #fff;
            color: #202124;
            font-family: "Helvetica Neue", "Luxi Sans", "DejaVu Sans", "Hiragino Sans GB", "Microsoft Yahei", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Segoe UI Symbol", "Android Emoji", "EmojiSymbols";
        }

        .fn__flex-column {
            display: flex;
            flex-direction: column;
            width: 100%;
            margin: 0 auto;
            border: 1px solid rgba(0, 0, 0, .06);
            min-height: 100vh;
            box-sizing: border-box;
            padding: 0 calc((100vw - 608px) / 2);
        }

        .fn__flex-1 {
            flex: 1;
            min-height: 16px;
            flex-shrink: 0;
        }

        h2 {
            margin: 0 0 4px 0;
            line-height: 24px;
            text-align: center;
        }

        .svg {
            position: fixed;
            right: 32px;
            top: 0;
            width: 13px;
            fill: #5f6368;
            padding: 9.5px;
            cursor: pointer;
            z-index: 1;
        }

        .svg:hover {
            background: #dfe0e1;
            fill: #202124;
        }

        #close {
            right: 0;
            width: 10px;
            padding: 11px 11px;
        }

        #close:hover {
            background-color: #d23f31;
            fill: #fff;
        }

        a {
            text-decoration: none;
            color: #218bff;
        }

        a:hover {
            text-decoration: underline;
            color: #0969da;
        }

        kbd {
            padding: 2px 4px;
            font: 75% Consolas, "Liberation Mono", Menlo, Courier, monospace;
            line-height: 1;
            color: #5f6368;
            vertical-align: middle;
            background-color: #f3f3f3;
            border: solid 1px rgba(0, 0, 0, .06);
            border-radius: 6px;
            box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .06);
        }

        .feedback {
            display: flex;
            justify-content: space-around;
            font-size: 14px
        }

        .drag {
            -webkit-app-region: drag;
            height: 32px;
            cursor: pointer;
            position: fixed;
            top: 0;
            left: 0;
            right: 44px;
        }

        #content div {
            line-height: 1.6;
            margin-top: 0;
            margin-bottom: 16px;
        }

        #content div:last-child {
            margin-bottom: 0;
        }

        #icon {
            position: fixed;
            left: 4px;
            top: 0;
            line-height: 32px;
            color: #5f6368;
        }

        #icon img {
            height: 32px;
            width: 32px;
            vertical-align: top;
        }

        pre code {
            background-color: #f8f9fa;
            border-radius: 6px;
            padding: 8px 16px;
            font-size: 85%;
            font-family: mononoki, Consolas, "Liberation Mono", Menlo, Courier, monospace, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Segoe UI Symbol", "Android Emoji", "EmojiSymbols";
            color: #5f6368;
            display: block;
            margin-top: 8px;
            word-break: break-all;
            white-space: pre-wrap;
        }
    </style>
</head>
<body>
<div class="fn__flex-column">
    <div class="fn__flex-1"></div>
    <h2 id="title"></h2>
    <div class="fn__flex-1"></div>
    <div id="content"></div>
    <div class="fn__flex-1"></div>
    <div class="feedback">
        <span><a href="https://ld246.com/article/1649901726096" target="_blank">求助反馈建议</a></span>
        <span><a href="https://b3log.org/siyuan/download.html" target="_blank">下载最新版</a></span>
    </div>
    <div class="feedback">
        <span><a href="https://liuyun.io/article/1686530886208" target="_blank">Feedback and support</a></span>
        <span><a href="https://b3log.org/siyuan/en/download.html" target="_blank">Download the latest version</a></span>
    </div>
    <div class="fn__flex-1"></div>
</div>
<svg class="svg" id="min" viewBox="0 0 32 32">
    <path d="M1.333 14.667h29.333q1.333 0 1.333 1.333v0q0 1.333-1.333 1.333h-29.333q-1.333 0-1.333-1.333v0q0-1.333 1.333-1.333z"></path>
</svg>
<svg class="svg" id="close" viewBox="0 0 32 32">
    <path d="M32 3.221l-12.779 12.779 12.779 12.779-3.221 3.221-12.779-12.779-12.779 12.779-3.221-3.221 12.779-12.779-12.779-12.779 3.221-3.221 12.779 12.779 12.779-12.779z"></path>
</svg>
<div id="icon"></div>
<div class="drag"></div>
<script>
    const getSearch = (key) => {
        if (window.location.search.indexOf('?') === -1) {
            return ''
        }
        let value = ''
        const data = window.location.search.split('?')[1].split('&')
        data.find(item => {
            const keyValue = item.split('=')
            if (keyValue[0] === key) {
                value = keyValue[1]
                return true
            }
        })
        return value
    }

    (() => {
        if (process.platform === 'darwin') {
            document.getElementById('min').style.display = 'none';
            document.getElementById('close').style.display = 'none';
            document.querySelector('.drag').style.right = '0';
            document.querySelector('#icon').style.left = '74px';
        } else {
            document.querySelector('#icon').style.right = '70px';
        }

        const os = require('os')
        const platformMap = {
            'darwin': 'macOS',
            'win32': 'Windows',
            'linux': 'Linux'
        }
        const platform = platformMap[process.platform] || process.platform
        const release = os.release()
        const arch = os.arch()
        const cpus = os.cpus()
        const cpuModel = cpus.length > 0 ? cpus[0].model : ''
        const systemInfo = `· ${platform} ${release} · ${arch} · ${cpuModel}`
        document.querySelector('#icon').innerHTML = `<img src="${decodeURIComponent(getSearch('icon'))}"> SiYuan v${getSearch('v')} ${systemInfo}`

        document.getElementById('title').innerHTML = decodeURIComponent(getSearch('title'))
        document.getElementById('content').innerHTML = decodeURIComponent(getSearch('content'))

        document.getElementById('close').addEventListener('click', () => {
            const {ipcRenderer} = require('electron')
            ipcRenderer.send("siyuan-cmd", "destroy");
        })
        document.getElementById('min').addEventListener('click', () => {
            const {ipcRenderer} = require('electron')
            ipcRenderer.send("siyuan-cmd", "minimize");
        })
    })()
</script>
</body>
</html>
